package com.lwy.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.lwy.dao.BookNoveMapper;
import com.lwy.entity.BookNove;
import com.lwy.service.impl.BookNoveServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
//小说controller控制层
@RestController
@RequestMapping("nove")
public class BookNoveController  {


    @Resource
    private BookNoveServiceImpl bookNoveService;
    //查询所有小说
    @RequestMapping("list")
    public List<BookNove> list(){
           return bookNoveService.list();
    }

    @RequestMapping("findName")
    public PageInfo<BookNove> findName(String title, Integer pageNum, Integer pageSize){
        return bookNoveService.page(title,pageNum,pageSize);
    }

    @RequestMapping("hotList")
    public List<BookNove> hotList(){
        return bookNoveService.hotList();
    }
    //    按创建时间查询
    @RequestMapping("newList")
    public List<BookNove> newList(){
        return  bookNoveService.newList();
    }
    //    综合查询小说
    @RequestMapping("completeList")
    public List<BookNove> completeList(){
        return bookNoveService.completeList();
    }

    @RequestMapping("carousel")
    public List<BookNove> car(){
        return bookNoveService.list(new QueryWrapper<BookNove>().eq("tag","女生"));
    }
    @RequestMapping("findById")
    public BookNove find(Integer id){
        return bookNoveService.findById(id);
    }
    //    小说分类
    @RequestMapping("findClass")
    public List<BookNove> AllFL(String title,Integer category,Integer serialize,String word,String hits,String create_time){
        return bookNoveService.AllFL(title,category,serialize,word,hits,create_time);
    }

    @RequestMapping("findByTag")
    public List<BookNove> tag(Integer category){
        return bookNoveService.list(new QueryWrapper<BookNove>().like("category",category));
    }

    @RequestMapping("findUid")
    public List<BookNove> uid(Integer uid){
        return bookNoveService.findByWork(uid);
    }
    //    新增
    @RequestMapping("save")
    public Object save(BookNove bookNove){
        return bookNoveService.save(bookNove);
    }
    //  修改
    @RequestMapping("edit")
    public Object edit(Integer id){
        return bookNoveService.edit(id);
    }
    //    小説推荐票
    @RequestMapping("recommend")
    public Integer recommend(Integer id,Integer recommend,Integer uid){
        return bookNoveService.recommend(id,recommend,uid);
    }
    @RequestMapping("up")
    public Integer up(Integer id,Integer up,Integer uid){
        return bookNoveService.up(id,up,uid);
    }
    @RequestMapping("editS")
    public Object s(BookNove bookNove){
        return bookNoveService.updateById(bookNove);
    }
}
